var FormClass = {
	qnty_elem : 'items_qnty',
	wrapper : 'items',
	ItemNamePrefix : 'item',
	action : '',
	PathToAjaxBackend : 'index.php',
	addForm : function()
	{
		var obj = this;
		var items_qnty = $('#'+obj.qnty_elem).attr("value");
		action='addContactForm';
		// Create new JsHttpRequest object.
	    var req = new JsHttpRequest();
	    
	    // Code automatically called on load finishing.
	    req.onreadystatechange = function() {
	        if (req.readyState == 4) {
	            //get errors from backend
	            if(req.responseText)
	            {
	                alert(req.responseText);
	            }
				//get data from backend		
	            if (req.responseJS.output)
	            {
				    items_qnty++;
	            	$("#"+obj.wrapper).append(req.responseJS.output);
					$('#'+obj.qnty_elem).attr("value",items_qnty);
	            }
			}
	    }
	    try_add_new_block = items_qnty;try_add_new_block++;
	    alert(obj.action);
	    // Prepare request object (automatically choose GET or POST).
	    req.open(null, obj.PathToAjaxBackend, true);
		req.send({items_qnty:try_add_new_block,action:obj.action});
	},
	remForm : function()
	{
		var obj = this;
		var items_qnty = $('#'+obj.qnty_elem).attr("value");
	    if(items_qnty > 0)
	    {
	        $("#"+obj.ItemNamePrefix+"_"+items_qnty).remove();
	    	items_qnty--;
	        $('#'+obj.qnty_elem).attr("value",items_qnty);
	    }
	    else return false;
	}
};
FormClass.prototype = {};
var ContactForm = FormClass;
ContactForm.qnty_elem = 'contacts_qnty';
ContactForm.wrapper = 'contacts';
ContactForm.action = 'addContactForm';
ContactForm.ItemNamePrefix = 'contact';
var EducationForm = FormClass;
EducationForm.qnty_elem = 'educations_qnty';
EducationForm.wrapper = 'educations';
//EducationForm.PathToAjaxBackend = PathToAjaxBackend;
EducationForm.action = 'addEducationForm';
EducationForm.ItemNamePrefix = 'education';
var ExperienceForm = FormClass;
ExperienceForm.qnty_elem = 'experiences_qnty';
ExperienceForm.wrapper = 'experiences';
//ExperienceForm.PathToAjaxBackend = PathToAjaxBackend;
ExperienceForm.action = 'addExperienceForm';
ExperienceForm.ItemNamePrefix = 'experience';
var LanguageForm = FormClass;
LanguageForm.qnty_elem = 'languages_qnty';
LanguageForm.wrapper = 'languages';
//LanguageForm.PathToAjaxBackend = PathToAjaxBackend;
LanguageForm.action = 'addLanguageForm';
LanguageForm.ItemNamePrefix = 'language';
var AdditionalForm = FormClass;
AdditionalForm.qnty_elem = 'additionals_qnty';
AdditionalForm.wrapper = 'additionals';
//AdditionalForm.PathToAjaxBackend = PathToAjaxBackend;
AdditionalForm.action = 'addAdditionalForm';
AdditionalForm.ItemNamePrefix = 'additional';
